package com.rescue.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rescue.context.BaseContext;
import com.rescue.forum.dto.IntegralQueryDTO;
import com.rescue.forum.entity.UserIntegralRecord;
import com.rescue.mapper.UserIntegralRecordMapper;
import com.rescue.result.PageResult;
import com.rescue.service.UserIntegralRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserIntegralRecordServiceImpl implements UserIntegralRecordService {
    @Autowired
    private UserIntegralRecordMapper userIntegralRecordMapper;
    /**
     * 分页查询积分使用情况
     * @param integralQueryDTO
     * @return
     */
    public PageResult page(IntegralQueryDTO integralQueryDTO) {
        PageHelper.startPage(integralQueryDTO.getPage(),integralQueryDTO.getPageSize());
        Page<UserIntegralRecord> page = userIntegralRecordMapper.page(integralQueryDTO.getCreateTimeStart(),integralQueryDTO.getCreateTimeEnd(), BaseContext.getCurrentId());
        return new PageResult(page.getTotal(),page.getResult());
    }
}
